import java.awt.Graphics;
import java.awt.Image;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import javax.swing.ImageIcon;
import javax.swing.JPanel;

public class Menu extends JPanel {
	private PanelButton bUjJatek;
	private PanelButton bRekordok;
	private PanelButton bBeallitasok;
	private PanelButton bUtmutato;
	private PanelButton bKilepes;
	private Image backGround;
	private Main window;
	private Game newGame;
	
	public Menu( Main w ) {
		window = w;
		backGround = (new ImageIcon(getClass().getResource("image/backGrounds/menuBackGround.jpg"))).getImage();
		bUjJatek = new PanelButton("image/buttons/ujJatek");
		bRekordok = new PanelButton("image/buttons/rekordok");
		bBeallitasok = new PanelButton("image/buttons/beallitasok");
		bUtmutato = new PanelButton("image/buttons/utmutato");
		bKilepes = new PanelButton("image/buttons/Kilep");
		
		newGame = new Game(window,this);
				
		this.setLayout(null);
		this.add(bKilepes);
		this.add(bUjJatek);
		this.add(bRekordok);
		this.add(bBeallitasok);
		this.add(bUtmutato);
				
		bKilepes.setBounds(670, 530, 110, 60);
		bUjJatek.setBounds(150,250,200,40);
		bRekordok.setBounds(150,300,200,40);
		bBeallitasok.setBounds(150,350,200,40);
		bUtmutato.setBounds(150,400,200,40);
		
		bKilepes.addMouseListener(new MouseAdapter() {
			public void mouseClicked(MouseEvent e) {
				System.exit(0);
			}
		});
		
		bKilepes.addMouseListener(new MouseAdapter() {
			public void mouseClicked(MouseEvent e) {
				System.exit(0);
			}
		});
		
		bUjJatek.addMouseListener(new MouseAdapter() {
			public void mouseClicked(MouseEvent e) {
				bUjJatek.setFocused(false);
				window.setContentPane(newGame);
				window.setVisible(true);
			}
		});
	}

	public void paintComponent(Graphics g)	{
		super.paintComponent(g);
		g.drawImage(backGround, 0, 0, 800, 600, this);
	}
}
